home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Tool Chest / !Interfaces / Universal Interfaces 2.0a1 / PInterfaces / MacTCP.p < prev    next >
Encoding:
Text File  |  1994-07-21  |  20.7 KB  |  870 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        MacTCP.p
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a1.1  ETO #15, MPW prerelease.  Sunday, July 17, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. }
  16.  
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT MacTCP;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __MACTCP__}
  27. {$SETC __MACTCP__ := 1}
  28.  
  29. {$I+}
  30. {$SETC MacTCPIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33.  
  34. {$IFC UNDEFINED __TYPES__}
  35. {$I Types.p}
  36. {$ENDC}
  37. {    ConditionalMacros.p                                            }
  38.  
  39. {$IFC UNDEFINED __APPLETALK__}
  40. {$I AppleTalk.p}
  41. {$ENDC}
  42. {    OSUtils.p                                                    }
  43. {        MixedMode.p                                                }
  44.  
  45. {$PUSH}
  46. {$ALIGN MAC68K}
  47. {$LibExport+}
  48.  
  49. CONST
  50.     inProgress                    = 1;                            { I/O in progress }
  51.     ipBadLapErr                    = -23000;                        { bad network configuration }
  52.     ipBadCnfgErr                = -23001;                        { bad IP configuration error }
  53.     ipNoCnfgErr                    = -23002;                        { missing IP or LAP configuration error }
  54.     ipLoadErr                    = -23003;                        { error in MacTCP load }
  55.     ipBadAddr                    = -23004;                        { error in getting address }
  56.     connectionClosing            = -23005;                        { connection is closing }
  57.     invalidLength                = -23006;
  58.     connectionExists            = -23007;                        { request conflicts with existing connection }
  59.     connectionDoesntExist        = -23008;                        { connection does not exist }
  60.     insufficientResources        = -23009;                        { insufficient resources to perform request }
  61.     invalidStreamPtr            = -23010;
  62.     streamAlreadyOpen            = -23011;
  63.     connectionTerminated        = -23012;
  64.     invalidBufPtr                = -23013;
  65.     invalidRDS                    = -23014;
  66.     invalidWDS                    = -23014;
  67.     openFailed                    = -23015;
  68.     commandTimeout                = -23016;
  69.     duplicateSocket                = -23017;
  70.  
  71. { Error codes from internal IP functions }
  72.     ipDontFragErr                = -23032;                        { Packet too large to send w/o fragmenting }
  73.     ipDestDeadErr                = -23033;                        { destination not responding }
  74.     icmpEchoTimeoutErr            = -23035;                        { ICMP echo timed-out }
  75.     ipNoFragMemErr                = -23036;                        { no memory to send fragmented pkt }
  76.     ipRouteErr                    = -23037;                        { can't route packet off-net }
  77.     nameSyntaxErr                = -23041;
  78.     cacheFault                    = -23042;
  79.     noResultProc                = -23043;
  80.     noNameServer                = -23044;
  81.     authNameErr                    = -23045;
  82.     noAnsErr                    = -23046;
  83.     dnrErr                        = -23047;
  84.     outOfMemory                    = -23048;
  85.  
  86.     BYTES_16WORD                = 2;                            { bytes per = 16, bit ip word }
  87.     BYTES_32WORD                = 4;                            { bytes per = 32, bit ip word }
  88.     BYTES_64WORD                = 8;                            { bytes per = 64, bit ip word }
  89.  
  90.     
  91. TYPE
  92. b_8 = CHAR;
  93.  
  94.     b_16 = INTEGER;
  95.  
  96.     b_32 = LONGINT;
  97.  
  98.     ip_addr = b_32;
  99.  
  100.     ip_addrbytes = RECORD
  101.         CASE INTEGER OF
  102.         0: (
  103.             addr:                        b_32;
  104.            );
  105.         1: (
  106.             bytes:                        ARRAY [0..3] OF CHAR;
  107.            );
  108.     END;
  109.  
  110.     wdsEntry = RECORD
  111.         length:                    INTEGER;                                { length of buffer }
  112.         ptr:                    ^CHAR;                                    { pointer to buffer }
  113.     END;
  114.     rdsEntry = RECORD
  115.         length:                    INTEGER;                                { length of buffer }
  116.         ptr:                    ^CHAR;                                    { pointer to buffer }
  117.     END;
  118.     BufferPtr = LONGINT;
  119.  
  120.     StreamPtr = LONGINT;
  121.  
  122.  
  123. CONST
  124.     netUnreach                    = 0;
  125.     hostUnreach                    = 1;
  126.     protocolUnreach                = 2;
  127.     portUnreach                    = 3;
  128.     fragReqd                    = 4;
  129.     sourceRouteFailed            = 5;
  130.     timeExceeded                = 6;
  131.     parmProblem                    = 7;
  132.     missingOption                = 8;
  133.  
  134.     
  135. TYPE
  136. ICMPMsgType = INTEGER;
  137.  
  138.     ip_port = b_16;
  139.  
  140.     ICMPReport = RECORD
  141.         streamPtr:                StreamPtr;
  142.         localHost:                ip_addr;
  143.         localPort:                ip_port;
  144.         remoteHost:                ip_addr;
  145.         remotePort:                ip_port;
  146.         reportType:                INTEGER;
  147.         optionalAddlInfo:        INTEGER;
  148.         optionalAddlInfoPtr:    LONGINT;
  149.     END;
  150.     OSErrProcPtr = ProcPtr;  { FUNCTION OSErr: OSErr; }
  151.     OSErrUPP = UniversalProcPtr;
  152.  
  153. CONST
  154.     uppOSErrProcInfo = $00000021; { FUNCTION (): 2 byte result; }
  155.  
  156. FUNCTION NewOSErrProc(userRoutine: OSErrProcPtr): OSErrUPP;
  157.     {$IFC NOT GENERATINGCFM }
  158.     INLINE $2E9F;
  159.     {$ENDC}
  160.  
  161. FUNCTION CallOSErrProc(userRoutine: OSErrUPP): OSErr;
  162.     {$IFC NOT GENERATINGCFM}
  163.     INLINE $205F, $4E90;
  164.     {$ENDC}
  165. TYPE
  166.     PtrProcPtr = ProcPtr;  { FUNCTION Ptr: Ptr; }
  167.     PtrUPP = UniversalProcPtr;
  168.  
  169. CONST
  170.     uppPtrProcInfo = $00000031; { FUNCTION (): 4 byte result; }
  171.  
  172. FUNCTION NewPtrProc(userRoutine: PtrProcPtr): PtrUPP;
  173.     {$IFC NOT GENERATINGCFM }
  174.     INLINE $2E9F;
  175.     {$ENDC}
  176.  
  177. FUNCTION CallPtrProc(userRoutine: PtrUPP): Ptr;
  178.     {$IFC NOT GENERATINGCFM}
  179.     INLINE $205F, $4E90;
  180.     {$ENDC}
  181. TYPE
  182.     BooleanProcPtr = ProcPtr;  { FUNCTION Boolean: BOOLEAN; }
  183.     BooleanUPP = UniversalProcPtr;
  184.  
  185. CONST
  186.     uppBooleanProcInfo = $00000011; { FUNCTION (): 1 byte result; }
  187.  
  188. FUNCTION NewBooleanProc(userRoutine: BooleanProcPtr): BooleanUPP;
  189.     {$IFC NOT GENERATINGCFM }
  190.     INLINE $2E9F;
  191.     {$ENDC}
  192.  
  193. FUNCTION CallBooleanProc(userRoutine: BooleanUPP): BOOLEAN;
  194.     {$IFC NOT GENERATINGCFM}
  195.     INLINE $205F, $4E90;
  196.     {$ENDC}
  197.  
  198. CONST
  199.     NUM_ALT_ADDRS                = 4;
  200.  
  201.  
  202. TYPE
  203.     hostInfo = RECORD
  204.         rtnCode:                LONGINT;
  205.         cname:                    ARRAY [0..254] OF CHAR;
  206.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  207.         addr:                    ARRAY [0..NUM_ALT_ADDRS-1] OF LONGINT;
  208.     END;
  209.  
  210. CONST
  211.     kA                            = 1;
  212.     kNS                            = 2;
  213.     kCNAME                        = 5;
  214.     kHINFO                        = 13;
  215.     kMX                            = 15;
  216.  
  217.     
  218. TYPE
  219. AddrClasses = INTEGER;
  220.  
  221.     HInfoRec = RECORD
  222.         cpuType:                ARRAY [0..29] OF CHAR;
  223.         osType:                    ARRAY [0..29] OF CHAR;
  224.     END;
  225.     MXRec = RECORD
  226.         preference:                INTEGER;
  227.         exchange:                ARRAY [0..254] OF CHAR;
  228.     END;
  229.     returnRec = RECORD
  230.         rtnCode:                LONGINT;
  231.         cname:                    ARRAY [0..254] OF CHAR;
  232.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  233.         CASE INTEGER OF
  234.         0: (
  235.             addr:                        ARRAY [0..NUM_ALT_ADDRS-1] OF LONGINT;
  236.            );
  237.         1: (
  238.             hinfo:                        HInfoRec;
  239.            );
  240.         2: (
  241.             mx:                            MXRec;
  242.            );
  243.     END;
  244.  
  245.     cacheEntryRecord = RECORD
  246.         cname:                    ^CHAR;
  247.         ctype:                    INTEGER;
  248.         cacheClass:                INTEGER;
  249.         ttl:                    LONGINT;
  250.         CASE INTEGER OF
  251.         0: (
  252.             name:                        ^CHAR;
  253.            );
  254.         1: (
  255.             addr:                        ip_addr;
  256.            );
  257.     END;
  258.  
  259.     EnumResultProcPtr = ProcPtr;  { PROCEDURE EnumResult(VAR cacheEntryRecordPtr: cacheEntryRecord; VAR userDataPtr: CHAR); }
  260.     EnumResultUPP = UniversalProcPtr;
  261.  
  262. CONST
  263.     uppEnumResultProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  264.  
  265. FUNCTION NewEnumResultProc(userRoutine: EnumResultProcPtr): EnumResultUPP;
  266.     {$IFC NOT GENERATINGCFM }
  267.     INLINE $2E9F;
  268.     {$ENDC}
  269.  
  270. PROCEDURE CallEnumResultProc(VAR cacheEntryRecordPtr: cacheEntryRecord; VAR userDataPtr: CHAR; userRoutine: EnumResultUPP);
  271.     {$IFC NOT GENERATINGCFM}
  272.     INLINE $205F, $4E90;
  273.     {$ENDC}
  274. TYPE
  275.     ResultProcPtr = ProcPtr;  { PROCEDURE Result(VAR hostInfoPtr: hostInfo; VAR userDataPtr: CHAR); }
  276.     ResultUPP = UniversalProcPtr;
  277.  
  278. CONST
  279.     uppResultProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  280.  
  281. FUNCTION NewResultProc(userRoutine: ResultProcPtr): ResultUPP;
  282.     {$IFC NOT GENERATINGCFM }
  283.     INLINE $2E9F;
  284.     {$ENDC}
  285.  
  286. PROCEDURE CallResultProc(VAR hostInfoPtr: hostInfo; VAR userDataPtr: CHAR; userRoutine: ResultUPP);
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $205F, $4E90;
  289.     {$ENDC}
  290. TYPE
  291.     Result2ProcPtr = ProcPtr;  { PROCEDURE Result2(VAR returnRecPtr: returnRec; VAR userDataPtr: CHAR); }
  292.     Result2UPP = UniversalProcPtr;
  293.  
  294. CONST
  295.     uppResult2ProcInfo = $000003C0; { PROCEDURE (4 byte param, 4 byte param); }
  296.  
  297. FUNCTION NewResult2Proc(userRoutine: Result2ProcPtr): Result2UPP;
  298.     {$IFC NOT GENERATINGCFM }
  299.     INLINE $2E9F;
  300.     {$ENDC}
  301.  
  302. PROCEDURE CallResult2Proc(VAR returnRecPtr: returnRec; VAR userDataPtr: CHAR; userRoutine: Result2UPP);
  303.     {$IFC NOT GENERATINGCFM}
  304.     INLINE $205F, $4E90;
  305.     {$ENDC}
  306.  
  307. FUNCTION OpenResolver(VAR fileName: CHAR): OSErr;
  308. FUNCTION StrToAddr(VAR hostName: CHAR; VAR hostInfoPtr: hostInfo; ResultProc: ResultUPP; VAR userDataPtr: CHAR): OSErr;
  309. FUNCTION AddrToStr(addr: LONGINT; VAR addrStr: CHAR): OSErr;
  310. FUNCTION EnumCache(enumResultProc: EnumResultUPP; VAR userDataPtr: CHAR): OSErr;
  311. FUNCTION AddrToName(addr: ip_addr; VAR hostInfoPtr: hostInfo; ResultProc: ResultUPP; VAR userDataPtr: CHAR): OSErr;
  312. FUNCTION HInfo(VAR hostName: CHAR; VAR returnRecPtr: returnRec; resultProc: Result2UPP; VAR userDataPtr: CHAR): OSErr;
  313. FUNCTION MXInfo(VAR hostName: CHAR; VAR returnRecPtr: returnRec; resultProc: Result2UPP; VAR userDataPtr: CHAR): OSErr;
  314. FUNCTION CloseResolver: OSErr;
  315. { csCode to get our IP address }
  316.  
  317. CONST
  318.     ipctlGetAddr                = 15;
  319.  
  320.  
  321. TYPE
  322.     GetAddrParamBlock = RECORD
  323.         qLink:                    ^QElem;
  324.         qType:                    INTEGER;
  325.         ioTrap:                    INTEGER;
  326.         ioCmdAddr:                Ptr;
  327.         ioCompletion:            UniversalProcPtr;
  328.         ioResult:                OSErr;
  329.         ioNamePtr:                StringPtr;
  330.         ioVRefNum:                INTEGER;
  331.         ioCRefNum:                INTEGER;
  332.         csCode:                    INTEGER;                                { standard I/O header }
  333.         ourAddress:                ip_addr;                                { our IP address }
  334.         ourNetMask:                LONGINT;                                { our IP net mask }
  335.     END;
  336. { control codes }
  337.  
  338. CONST
  339.     ipctlEchoICMP                = 17;                            { send icmp echo }
  340.     ipctlLAPStats                = 19;                            { get lap stats }
  341.  
  342.  
  343. TYPE
  344.     ICMPParamBlock = RECORD
  345.         qLink:                    ^QElem;
  346.         qType:                    INTEGER;
  347.         ioTrap:                    INTEGER;
  348.         ioCmdAddr:                Ptr;
  349.         ioCompletion:            UniversalProcPtr;
  350.         ioResult:                OSErr;
  351.         ioNamePtr:                StringPtr;
  352.         ioVRefNum:                INTEGER;
  353.         ioCRefNum:                INTEGER;
  354.         csCode:                    INTEGER;                                { standard I/O header }
  355.         params:                    ARRAY [0..10] OF INTEGER;
  356.         icmpEchoInfo:            RECORD
  357.                 echoRequestOut:                    LONGINT;                        { time in ticks of when the echo request went out }
  358.                 echoReplyIn:                    LONGINT;                        { time in ticks of when the reply was received }
  359.                 echoedData:                        rdsEntry;                        { data received in responce }
  360.                 options:                        Ptr;
  361.                 userDataPtr:                    LONGINT;
  362.             END;
  363.  
  364.     END;
  365.  
  366. CONST
  367.     NBP_TABLE_SIZE                = 20;                            { number of NBP table entries }
  368.     NBP_MAX_NAME_SIZE            = 16 + 10 + 2;
  369.  
  370.  
  371. TYPE
  372.     nbp_entry = RECORD
  373.         ip_address:                ip_addr;                                { IP address }
  374.         at_address:                AddrBlock;                                { matching AppleTalk address }
  375.         gateway:                BOOLEAN;                                { TRUE if entry for a gateway }
  376.         valid:                    BOOLEAN;                                { TRUE if LAP address is valid }
  377.         probing:                BOOLEAN;                                { TRUE if NBP lookup pending }
  378.         afiller:                SInt8;                                    { Filler for proper byte alignment     }
  379.         age:                    LONGINT;                                { ticks since cache entry verified }
  380.         access:                    LONGINT;                                { ticks since last access }
  381.         filler:                    ARRAY [0..115] OF CHAR;                    { for internal use only !!! }
  382.     END;
  383. { number of ARP table entries }
  384.  
  385. CONST
  386.     ARP_TABLE_SIZE                = 20;
  387.  
  388.  
  389. TYPE
  390.     Enet_addr = RECORD
  391.         en_hi:                    b_16;
  392.         en_lo:                    b_32;
  393.     END;
  394.     arp_entry = RECORD
  395.         age:                    INTEGER;                                { cache aging field }
  396.         protocol:                b_16;                                    { Protocol type }
  397.         ip_address:                ip_addr;                                { IP address }
  398.         en_address:                Enet_addr;                                { matching Ethernet address }
  399.     END;
  400. { Command codes }
  401.  
  402. CONST
  403.     TCPCreate                    = 30;
  404.     TCPPassiveOpen                = 31;
  405.     TCPActiveOpen                = 32;
  406.     TCPSend                        = 34;
  407.     TCPNoCopyRcv                = 35;
  408.     TCPRcvBfrReturn                = 36;
  409.     TCPRcv                        = 37;
  410.     TCPClose                    = 38;
  411.     TCPAbort                    = 39;
  412.     TCPStatus                    = 40;
  413.     TCPExtendedStat                = 41;
  414.     TCPRelease                    = 42;
  415.     TCPGlobalInfo                = 43;
  416.     TCPCtlMax                    = 49;
  417.  
  418. TYPE
  419.     ICMPEchoNotifyProcPtr = ProcPtr;  { PROCEDURE ICMPEchoNotify(VAR iopb: ICMPParamBlock); }
  420.     ICMPEchoNotifyUPP = UniversalProcPtr;
  421.  
  422. CONST
  423.     uppICMPEchoNotifyProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  424.  
  425. FUNCTION NewICMPEchoNotifyProc(userRoutine: ICMPEchoNotifyProcPtr): ICMPEchoNotifyUPP;
  426.     {$IFC NOT GENERATINGCFM }
  427.     INLINE $2E9F;
  428.     {$ENDC}
  429.  
  430. PROCEDURE CallICMPEchoNotifyProc(VAR iopb: ICMPParamBlock; userRoutine: ICMPEchoNotifyUPP);
  431.     {$IFC NOT GENERATINGCFM}
  432.     INLINE $205F, $4E90;
  433.     {$ENDC}
  434.  
  435. TYPE
  436.     IPParamBlock = RECORD
  437.         qLink:                    ^QElem;
  438.         qType:                    INTEGER;
  439.         ioTrap:                    INTEGER;
  440.         ioCmdAddr:                Ptr;
  441.         ioCompletion:            UniversalProcPtr;
  442.         ioResult:                OSErr;
  443.         ioNamePtr:                StringPtr;
  444.         ioVRefNum:                INTEGER;
  445.         ioCRefNum:                INTEGER;
  446.         csCode:                    INTEGER;                                { standard I/O header }
  447.         CASE INTEGER OF
  448.         0: (
  449.             dest:                        ip_addr;                            { echo to IP address }
  450.             data:                        wdsEntry;
  451.             timeout:                    INTEGER;
  452.             options:                    Ptr;
  453.             optLength:                    INTEGER;
  454.             icmpCompletion:                ICMPEchoNotifyUPP;
  455.             userDataPtr:                LONGINT;
  456.            );
  457.         1: (
  458.             lapStatsPtr:                ^LAPStats;
  459.            );
  460.     END;
  461.  
  462.     AddressXlation = RECORD
  463.         CASE INTEGER OF
  464.         0: (
  465.             arp_table:                    ^arp_entry;
  466.            );
  467.         1: (
  468.             nbp_table:                    ^nbp_entry;
  469.            );
  470.     END;
  471.  
  472.     LAPStats = RECORD
  473.         ifType:                    INTEGER;
  474.         ifString:                ^CHAR;
  475.         ifMaxMTU:                INTEGER;
  476.         ifSpeed:                LONGINT;
  477.         ifPhyAddrLength:        INTEGER;
  478.         ifPhysicalAddress:        ^CHAR;
  479.         AddrXlation:            AddressXlation;
  480.         slotNumber:                INTEGER;
  481.     END;
  482.  
  483.  
  484. CONST
  485.     TCPClosing                    = 1;
  486.     TCPULPTimeout                = 2;
  487.     TCPTerminate                = 3;
  488.     TCPDataArrival                = 4;
  489.     TCPUrgent                    = 5;
  490.     TCPICMPReceived                = 6;
  491.  
  492.     
  493. TYPE
  494. TCPEventCode = INTEGER;
  495.  
  496.  
  497. CONST
  498.     TCPRemoteAbort                = 2;
  499.     TCPNetworkFailure            = 3;
  500.     TCPSecPrecMismatch            = 4;
  501.     TCPULPTimeoutTerminate        = 5;
  502.     TCPULPAbort                    = 6;
  503.     TCPULPClose                    = 7;
  504.     TCPServiceError                = 8;
  505.  
  506.     
  507. TYPE
  508. TCPTerminationReason = INTEGER;
  509.  
  510.     TCPNotifyProcPtr = ProcPtr;  { PROCEDURE TCPNotify(tcpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; terminReason: INTEGER; VAR icmpMsg: ICMPReport); }
  511.     TCPNotifyUPP = UniversalProcPtr;
  512.  
  513. CONST
  514.     uppTCPNotifyProcInfo = $0000EEC0; { PROCEDURE (4 byte param, 2 byte param, 4 byte param, 2 byte param, 4 byte param); }
  515.  
  516. FUNCTION NewTCPNotifyProc(userRoutine: TCPNotifyProcPtr): TCPNotifyUPP;
  517.     {$IFC NOT GENERATINGCFM }
  518.     INLINE $2E9F;
  519.     {$ENDC}
  520.  
  521. PROCEDURE CallTCPNotifyProc(tcpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; terminReason: INTEGER; VAR icmpMsg: ICMPReport; userRoutine: TCPNotifyUPP);
  522.     {$IFC NOT GENERATINGCFM}
  523.     INLINE $205F, $4E90;
  524.     {$ENDC}
  525.     
  526. TYPE
  527. tcp_port = INTEGER;
  528.  
  529. { ValidityFlags }
  530.  
  531. CONST
  532.     timeoutValue                = $80;
  533.     timeoutAction                = $40;
  534.     typeOfService                = $20;
  535.     precedence                    = $10;
  536.  
  537. { TOSFlags }
  538.     lowDelay                    = $01;
  539.     throughPut                    = $02;
  540.     reliability                    = $04;
  541.  
  542.  
  543. TYPE
  544.     TCPCreatePB = RECORD
  545.         rcvBuff:                Ptr;
  546.         rcvBuffLen:                LONGINT;
  547.         notifyProc:                TCPNotifyUPP;
  548.         userDataPtr:            Ptr;
  549.     END;
  550.     TCPOpenPB = RECORD
  551.         ulpTimeoutValue:        SInt8;
  552.         ulpTimeoutAction:        SInt8;
  553.         validityFlags:            SInt8;
  554.         commandTimeoutValue:    SInt8;
  555.         remoteHost:                ip_addr;
  556.         remotePort:                tcp_port;
  557.         localHost:                ip_addr;
  558.         localPort:                tcp_port;
  559.         tosFlags:                SInt8;
  560.         precedence:                SInt8;
  561.         dontFrag:                BOOLEAN;
  562.         timeToLive:                SInt8;
  563.         security:                SInt8;
  564.         optionCnt:                SInt8;
  565.         options:                ARRAY [0..39] OF SInt8;
  566.         userDataPtr:            Ptr;
  567.     END;
  568.     TCPSendPB = RECORD
  569.         ulpTimeoutValue:        SInt8;
  570.         ulpTimeoutAction:        SInt8;
  571.         validityFlags:            SInt8;
  572.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  573.         pushFlag:                BOOLEAN;
  574.         urgentFlag:                BOOLEAN;
  575.         wdsPtr:                    Ptr;
  576.         sendFree:                LONGINT;
  577.         sendLength:                INTEGER;
  578.         userDataPtr:            Ptr;
  579.     END;
  580. { for receive and return rcv buff calls }
  581.     TCPReceivePB = RECORD
  582.         commandTimeoutValue:    SInt8;
  583.         filler:                    SInt8;
  584.         markFlag:                BOOLEAN;
  585.         urgentFlag:                BOOLEAN;
  586.         rcvBuff:                Ptr;
  587.         rcvBuffLen:                INTEGER;
  588.         rdsPtr:                    Ptr;
  589.         rdsLength:                INTEGER;
  590.         secondTimeStamp:        INTEGER;
  591.         userDataPtr:            Ptr;
  592.     END;
  593.     TCPClosePB = RECORD
  594.         ulpTimeoutValue:        SInt8;
  595.         ulpTimeoutAction:        SInt8;
  596.         validityFlags:            SInt8;
  597.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  598.         userDataPtr:            Ptr;
  599.     END;
  600.     HistoBucket = RECORD
  601.         value:                    INTEGER;
  602.         counter:                LONGINT;
  603.     END;
  604.  
  605. CONST
  606.     NumOfHistoBuckets            = 7;
  607.  
  608.  
  609. TYPE
  610.     TCPConnectionStats = RECORD
  611.         dataPktsRcvd:            LONGINT;
  612.         dataPktsSent:            LONGINT;
  613.         dataPktsResent:            LONGINT;
  614.         bytesRcvd:                LONGINT;
  615.         bytesRcvdDup:            LONGINT;
  616.         bytesRcvdPastWindow:    LONGINT;
  617.         bytesSent:                LONGINT;
  618.         bytesResent:            LONGINT;
  619.         numHistoBuckets:        INTEGER;
  620.         sentSizeHisto:            ARRAY [0..NumOfHistoBuckets-1] OF HistoBucket;
  621.         lastRTT:                INTEGER;
  622.         tmrSRTT:                INTEGER;
  623.         rttVariance:            INTEGER;
  624.         tmrRTO:                    INTEGER;
  625.         sendTries:                SInt8;
  626.         sourchQuenchRcvd:        SInt8;
  627.     END;
  628.     TCPStatusPB = RECORD
  629.         ulpTimeoutValue:        SInt8;
  630.         ulpTimeoutAction:        SInt8;
  631.         unused:                    LONGINT;
  632.         remoteHost:                ip_addr;
  633.         remotePort:                tcp_port;
  634.         localHost:                ip_addr;
  635.         localPort:                tcp_port;
  636.         tosFlags:                SInt8;
  637.         precedence:                SInt8;
  638.         connectionState:        SInt8;
  639.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  640.         sendWindow:                INTEGER;
  641.         rcvWindow:                INTEGER;
  642.         amtUnackedData:            INTEGER;
  643.         amtUnreadData:            INTEGER;
  644.         securityLevelPtr:        Ptr;
  645.         sendUnacked:            LONGINT;
  646.         sendNext:                LONGINT;
  647.         congestionWindow:        LONGINT;
  648.         rcvNext:                LONGINT;
  649.         srtt:                    LONGINT;
  650.         lastRTT:                LONGINT;
  651.         sendMaxSegSize:            LONGINT;
  652.         connStatPtr:            ^TCPConnectionStats;
  653.         userDataPtr:            Ptr;
  654.     END;
  655.     TCPAbortPB = RECORD
  656.         userDataPtr:            Ptr;
  657.     END;
  658.     TCPParam = RECORD
  659.         tcpRtoA:                LONGINT;
  660.         tcpRtoMin:                LONGINT;
  661.         tcpRtoMax:                LONGINT;
  662.         tcpMaxSegSize:            LONGINT;
  663.         tcpMaxConn:                LONGINT;
  664.         tcpMaxWindow:            LONGINT;
  665.     END;
  666.     TCPStats = RECORD
  667.         tcpConnAttempts:        LONGINT;
  668.         tcpConnOpened:            LONGINT;
  669.         tcpConnAccepted:        LONGINT;
  670.         tcpConnClosed:            LONGINT;
  671.         tcpConnAborted:            LONGINT;
  672.         tcpOctetsIn:            LONGINT;
  673.         tcpOctetsOut:            LONGINT;
  674.         tcpOctetsInDup:            LONGINT;
  675.         tcpOctetsRetrans:        LONGINT;
  676.         tcpInputPkts:            LONGINT;
  677.         tcpOutputPkts:            LONGINT;
  678.         tcpDupPkts:                LONGINT;
  679.         tcpRetransPkts:            LONGINT;
  680.     END;
  681.     StreamPPtr = ^StreamPtr;
  682.  
  683.     TCPGlobalInfoPB = RECORD
  684.         tcpParamPtr:            ^TCPParam;
  685.         tcpStatsPtr:            ^TCPStats;
  686.         tcpCDBTable:            ARRAY [0..0] OF StreamPPtr;
  687.         userDataPtr:            Ptr;
  688.         maxTCPConnections:        INTEGER;
  689.     END;
  690.     TCPIOCompletionProcPtr = ProcPtr;  { PROCEDURE TCPIOCompletion(VAR iopb: TCPiopb); }
  691.     TCPIOCompletionUPP = UniversalProcPtr;
  692.  
  693.     TCPiopb = RECORD
  694.         fill12:                    ARRAY [0..11] OF CHAR;
  695.         ioCompletion:            TCPIOCompletionUPP;
  696.         ioResult:                INTEGER;
  697.         ioNamePtr:                ^CHAR;
  698.         ioVRefNum:                INTEGER;
  699.         ioCRefNum:                INTEGER;
  700.         csCode:                    INTEGER;
  701.         tcpStream:                StreamPtr;
  702.         CASE INTEGER OF
  703.         0: (
  704.             create:                        TCPCreatePB;
  705.            );
  706.         1: (
  707.             open:                        TCPOpenPB;
  708.            );
  709.         2: (
  710.             send:                        TCPSendPB;
  711.            );
  712.         3: (
  713.             receive:                    TCPReceivePB;
  714.            );
  715.         4: (
  716.             close:                        TCPClosePB;
  717.            );
  718.         5: (
  719.             abort:                        TCPAbortPB;
  720.            );
  721.         6: (
  722.             status:                        TCPStatusPB;
  723.            );
  724.         7: (
  725.             globalInfo:                    TCPGlobalInfoPB;
  726.            );
  727.     END;
  728.  
  729.  
  730. CONST
  731.     uppTCPIOCompletionProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  732.  
  733. FUNCTION NewTCPIOCompletionProc(userRoutine: TCPIOCompletionProcPtr): TCPIOCompletionUPP;
  734.     {$IFC NOT GENERATINGCFM }
  735.     INLINE $2E9F;
  736.     {$ENDC}
  737.  
  738. PROCEDURE CallTCPIOCompletionProc(VAR iopb: TCPiopb; userRoutine: TCPIOCompletionUPP);
  739.     {$IFC NOT GENERATINGCFM}
  740.     INLINE $205F, $4E90;
  741.     {$ENDC}
  742.  
  743. CONST
  744.     UDPCreate                    = 20;
  745.     UDPRead                        = 21;
  746.     UDPBfrReturn                = 22;
  747.     UDPWrite                    = 23;
  748.     UDPRelease                    = 24;
  749.     UDPMaxMTUSize                = 25;
  750.     UDPStatus                    = 26;
  751.     UDPMultiCreate                = 27;
  752.     UDPMultiSend                = 28;
  753.     UDPMultiRead                = 29;
  754.     UDPCtlMax                    = 29;
  755.  
  756.     UDPDataArrival                = 1;
  757.     UDPICMPReceived                = 2;
  758.  
  759.     
  760. TYPE
  761. UDPEventCode = INTEGER;
  762.  
  763.     UDPNotifyProcPtr = ProcPtr;  { PROCEDURE UDPNotify(udpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; VAR icmpMsg: ICMPReport); }
  764.     UDPNotifyUPP = UniversalProcPtr;
  765.  
  766. CONST
  767.     uppUDPNotifyProcInfo = $00003EC0; { PROCEDURE (4 byte param, 2 byte param, 4 byte param, 4 byte param); }
  768.  
  769. FUNCTION NewUDPNotifyProc(userRoutine: UDPNotifyProcPtr): UDPNotifyUPP;
  770.     {$IFC NOT GENERATINGCFM }
  771.     INLINE $2E9F;
  772.     {$ENDC}
  773.  
  774. PROCEDURE CallUDPNotifyProc(udpStream: StreamPtr; eventCode: INTEGER; userDataPtr: Ptr; VAR icmpMsg: ICMPReport; userRoutine: UDPNotifyUPP);
  775.     {$IFC NOT GENERATINGCFM}
  776.     INLINE $205F, $4E90;
  777.     {$ENDC}
  778.     
  779. TYPE
  780. udp_port = INTEGER;
  781.  
  782. { for create and release calls }
  783.     UDPCreatePB = RECORD
  784.         rcvBuff:                Ptr;
  785.         rcvBuffLen:                LONGINT;
  786.         notifyProc:                UDPNotifyUPP;
  787.         localPort:                INTEGER;
  788.         userDataPtr:            Ptr;
  789.         endingPort:                udp_port;
  790.     END;
  791.     UDPSendPB = RECORD
  792.         reserved:                INTEGER;
  793.         remoteHost:                ip_addr;
  794.         remotePort:                udp_port;
  795.         wdsPtr:                    Ptr;
  796.         checkSum:                BOOLEAN;
  797.         filler:                    SInt8;                                    { Filler for proper byte alignment     }
  798.         sendLength:                INTEGER;
  799.         userDataPtr:            Ptr;
  800.         localPort:                udp_port;
  801.     END;
  802. { for receive and buffer return calls }
  803.     UDPReceivePB = RECORD
  804.         timeOut:                INTEGER;
  805.         remoteHost:                ip_addr;
  806.         remotePort:                udp_port;
  807.         rcvBuff:                Ptr;
  808.         rcvBuffLen:                INTEGER;
  809.         secondTimeStamp:        INTEGER;
  810.         userDataPtr:            Ptr;
  811.         destHost:                ip_addr;                                { only for use with multi rcv }
  812.         destPort:                udp_port;                                { only for use with multi rcv }
  813.     END;
  814.     UDPMTUPB = RECORD
  815.         mtuSize:                INTEGER;
  816.         remoteHost:                ip_addr;
  817.         userDataPtr:            Ptr;
  818.     END;
  819.     UDPIOCompletionProcPtr = ProcPtr;  { PROCEDURE UDPIOCompletion(VAR iopb: UDPiopb); }
  820.     UDPIOCompletionUPP = UniversalProcPtr;
  821.  
  822.     UDPiopb = RECORD
  823.         fill12:                    ARRAY [0..11] OF CHAR;
  824.         ioCompletion:            UDPIOCompletionUPP;
  825.         ioResult:                INTEGER;
  826.         ioNamePtr:                ^CHAR;
  827.         ioVRefNum:                INTEGER;
  828.         ioCRefNum:                INTEGER;
  829.         csCode:                    INTEGER;
  830.         udpStream:                StreamPtr;
  831.         CASE INTEGER OF
  832.         0: (
  833.             create:                        UDPCreatePB;
  834.            );
  835.         1: (
  836.             send:                        UDPSendPB;
  837.            );
  838.         2: (
  839.             receive:                    UDPReceivePB;
  840.            );
  841.         3: (
  842.             mtu:                        UDPMTUPB;
  843.            );
  844.     END;
  845.  
  846.  
  847. CONST
  848.     uppUDPIOCompletionProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  849.  
  850. FUNCTION NewUDPIOCompletionProc(userRoutine: UDPIOCompletionProcPtr): UDPIOCompletionUPP;
  851.     {$IFC NOT GENERATINGCFM }
  852.     INLINE $2E9F;
  853.     {$ENDC}
  854.  
  855. PROCEDURE CallUDPIOCompletionProc(VAR iopb: UDPiopb; userRoutine: UDPIOCompletionUPP);
  856.     {$IFC NOT GENERATINGCFM}
  857.     INLINE $205F, $4E90;
  858.     {$ENDC}
  859.  
  860. {$ALIGN RESET}
  861. {$POP}
  862.  
  863. {$SETC UsingIncludes := MacTCPIncludes}
  864.  
  865. {$ENDC} {__MACTCP__}
  866.  
  867. {$IFC NOT UsingIncludes}
  868.  END.
  869. {$ENDC}
  870.